<!DOCTYPE html>
<html>

<head>
    <title>市民疫情网后台</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">

    <script src="{{ url_for('static',filename='/libs/layui/layui.all.js') }}"></script>
    <!-- 引入css -->
    <link rel="stylesheet"
          href="{{ url_for('static',filename='/css/plugins/font-awesome-4.7.0/css/font-awesome.min.css') }}">
    <link rel="stylesheet" href="{{ url_for('static',filename='/libs/layui/css/layui.css') }}">
    <link rel="stylesheet" href="{{ url_for('static',filename='/css/admin_main.css') }}">
</head>

<body class="layui-layout-login">
<div class="login-bg">
    <div class="cover"></div>
</div>
<div class="login-content">
    <h1 class="login-box-title"><i class="fa fa-fw fa-user"></i>疫情后台登录</h1>
    <form class="layui-form">
        <div class="layui-form-item">
            <label class="layui-icon layui-icon-username" for="username"></label>
            <input class="layui-input" type="text" name="username" id="username" placeholder="用户名">
        </div>
        <div class="layui-form-item">
            <label class="layui-icon layui-icon-password" for="password"></label>
            <input class="layui-input" type="password" name="password" id="password" placeholder="密码">
        </div>

        <button id="login" class="layui-btn layui-btn-fluid ajax-submit"><i
                class="fa fa-sign-in fa-lg fa-fw"></i> 登录
        </button>
    </form>
</div>

<script src="{{ url_for('static',filename='/libs/jquery-3.5.1.min.js') }}"></script>
<script src="{{ url_for('static',filename='/libs/layui/layui.js') }}"></script>

<script>
    $("#login").click(function (e) {
        e.preventDefault();
        var username = $("#username").val();
        var password = $("#password").val();
        if (username == "") {
            layer.msg("账号不为空！");
            return false;
        }
        if (password == "") {
            layer.msg("密码不为空！");
            return false;
        }
        $.ajax({
            url: "/admin/login",
            type: "POST",
            data: {
                "username": username,
                "password": password
            },
            success: function (data) {
                if (data.result == 200) {
                    layer.msg('登录中······', {
                        icon: 16
                        , shade: 0.01
                        , time: 1000
                    }, function () {
                        window.location.href = "/admin/index";
                    });

                } else {
                    layer.msg("账号信息输入有误！")
                }
            }
        })

    })
</script>
</body>

</html>